//导入测试数据
import ChannelData from './data/Channel.json'
import EquipmentData from './data/Equipment.json'
import SubstationData from './data/Substation.json'
import CableSectionData from './data/CableSection.json'

import TaskData from './data/Task.json'
import CableWellData from './data/CableWell.json'

const insertTask = function() {
	uni.$model("task", m => {
		m.insert(TaskData.Task, (err, result) => {
			console.log(err);
			//console.log(results);
			if (!err) console.log('task 增加成功');
		})
	})
}

const insertSubstation = function() {
	uni.$model("substation", m => {
		m.insert(SubstationData.Substation, (err, result) => {
			console.log(err);
			//console.log(results);
			if (!err) console.log('substation 增加成功');
		})
	})
}

const insertCableSection = function() {
	uni.$model("cablesection", m => {
		m.insert(CableSectionData.CableSection, (err, result) => {
			console.log(err);
			//console.log(results);
			if (!err) console.log('cablesection 增加成功');
		})
	})
}

const insertCableWell = function() {
	uni.$model("cableweel", m => {
		m.insert(CableWellData.CableWell, (err, result) => {
			console.log(err);
			//console.log(results);
			if (!err) console.log('cableweel 增加成功');
		})
	})
}

const insertChannel = function() {
	uni.$model("cableweel", m => {
		m.insert(CableWellData.CableWell, (err, result) => {
			console.log(err);
			//console.log(results);
			if (!err) console.log('cableweel 增加成功');
		})
	})
}

const insertEquipment = function() {
	uni.$model("equipment", m => {
		m.insert(EquipmentData.Equipment, (err, result) => {
			console.log(err);
			//console.log(results);
			if (!err) console.log('equipment 增加成功');
		})
	})
}



const insertTestData = async () => {
	console.log("加载测试数据")
	return new Promise(resolve => {
		insertSubstation();
		insertCableSection();
		insertCableWell();
		insertChannel();
		insertEquipment();
		resolve(true)
	});
}

export {
	insertTask,
	insertSubstation,
	insertCableSection,
	insertCableWell,
	insertChannel,
	insertEquipment, 
	insertTestData
}
